<template>
  <div>
    <el-card class="box-card">
      <div slot="header" style="text-align:left">
        <el-form :inline="true" :model="searchForm" class="demo-form-inline">
          <el-form-item label="手机号">
            <el-input v-model="searchForm.phone" placeholder="手机号"></el-input>
          </el-form-item>
          <el-form-item label="会员名称">
             <el-input v-model="searchForm.username" placeholder="会员名称"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-table :data="members" border style="width: 100%">
        <el-table-column prop="avatar" label="头像" style="width: 20%">
              <template slot-scope="scope">
                  <img width=50 height=50 v-if="scope.row.avatar && scope.row.avatar.length>0" :src="scope.row.avatar">
                  <span v-else>无图</span>
              </template>
          </el-table-column>
        <el-table-column prop="username" label="用户名" style="width: 20%"></el-table-column>
        <el-table-column prop="phone" label="手机" style="width: 50%"></el-table-column>
         <el-table-column prop="email" label="邮箱" style="width: 50%"></el-table-column>
          <el-table-column prop="score" label="积分" style="width: 50%"></el-table-column>
        <el-table-column prop="createtime" label="注册时间" style="width: 50%"></el-table-column>
    
        <el-table-column label="操作" style="width: 10%">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="detail(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top:10px;">
        <el-pagination
          background
          @current-change="handleCurrentChange"
          :current-page.sync="pagenow"
          :page-size="pagesize"
          layout="total, prev, pager, next"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import { memberList } from "@/libs/api.js";
export default {
  methods: {
    handleCurrentChange(p) {
      this.loadPage(p);
    },
    onSubmit() {
      this.pagenow = 1;
      this.loadPage();
    },
    loadPage() {
      var param = { pagesize: 10, pagenow: this.pagenow,"phone":this.searchForm.phone,"username":this.searchForm.username};
      memberList(param).then(res => {
        this.members = res.rows;
        this.total = res.total;
      });
    }
  },

  mounted() {
    this.loadPage();
  },

  data() {
    return {
      members: [],
      total: 0,
      pagenow: 1,
      pagesize: 10,
      searchForm: {
        phone: "",
        username: ""
      }
    };
  }
};
</script>